#include"Common.h"

#include"Ex1_1.h"

void ExportLua(lua_State* L)
{
  lua_tinker::class_add<CPoint>(L, "Point");
  lua_tinker::class_con<CPoint>(L, lua_tinker::constructor<CPoint, U32, U32>);

  lua_tinker::class_def<CPoint>(L, "SetPointX",     &CPoint::SetPointX);
  lua_tinker::class_def<CPoint>(L, "SetPointY",     &CPoint::SetPointY);
  lua_tinker::class_def<CPoint>(L, "GetPointX",     &CPoint::GetPointX);
  lua_tinker::class_def<CPoint>(L, "GetPointY",     &CPoint::GetPointY);
  lua_tinker::class_def<CPoint>(L, "SetPoint",      &CPoint::SetPoint);

  typedef std::vector<CPoint> VctPoint;
  lua_tinker::class_add<VctPoint>(L, "VctPoint");
  lua_tinker::class_con<VctPoint>(L, lua_tinker::constructor<VctPoint, S32>);

  //typedef void (VctPoint::*fp)();
  //fp front = &VctPoint::front;
  //fp back = &VctPoint::back;
  //fp begin = &VctPoint::begin;
  //fp end = &VctPoint::end;

  lua_tinker::class_def<VctPoint>(L, "push_back",       &VctPoint::push_back);
  lua_tinker::class_def<VctPoint>(L, "pop_back",        &VctPoint::pop_back);
  lua_tinker::class_def<VctPoint>(L, "size",            &VctPoint::size);
  //lua_tinker::class_def<VctPoint>(L, "front",           front);
  //lua_tinker::class_def<VctPoint>(L, "back",            back);
  //lua_tinker::class_def<VctPoint>(L, "begin",           begin);
  //lua_tinker::class_def<VctPoint>(L, "end",             end);
  lua_tinker::class_def<VctPoint>(L, "clear",           &VctPoint::clear);

}

int main()
{
  lua_State* L = lua_open();
  luaL_openlibs(L);
  ExportLua(L);

  lua_tinker::dofile(L, GAMEDATADIR"/Main.lua");
  lua_tinker::call<void>(L, "Test");
  lua_close(L);
  return 0;
}